<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>

		<title >登录</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- ajax csrf -->
	<!--	<meta name="_csrf" th:content="${_csrf.token}"/>
		<meta name="_csrf_header" th:content="${_csrf.headerName}"/>-->
		<!-- basic styles -->
		<link type="text/css"  rel="stylesheet"  th:href="@{/css/ace/css/bootstrap.min.css}" />
		<link type="text/css"  rel="stylesheet"  th:href="@{/css/ace/css/font-awesome.min.css}" />
		<link type="text/css"  rel="stylesheet"  th:href="@{/css/common.css}" />

		<!-- ace styles -->
		<link type="text/css" rel="stylesheet" th:href="@{/css/ace/css/ace.min.css}" />
		<link type="text/css" rel="stylesheet" th:href="@{/css/ace/css/ace-rtl.min.css}" />

		<!--[if IE 7]>
		<link type="text/css" rel="stylesheet" th:href="@{/css/ace/css/font-awesome-ie7.min.css}" />
		<![endif]-->

		<!--[if lte IE 8]>
		<link type="text/css" rel="stylesheet" th:href="@{/css/ace/css/ace-ie.min.css}" />
		<![endif]-->

	</head>

	<body class="login-layout">
		<div class="main-container">
			<div class="main-content">
				<div class="row">
					<div class="col-sm-10 col-sm-offset-1" style="margin-top:150px">
						<div class="login-container">
							<div class="center">
								<h1>
									<i class="icon-leaf green"></i>
									<span class="red">调查系统</span>
									<span class="white">管理后台</span>
								</h1>
							</div>

							<div class="space-6"></div>

							<div class="position-relative">
								<div id="login-box" class="login-box visible widget-box no-border" >
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header blue lighter bigger">
												<i class="icon-coffee green"></i>
												 欢迎使用管理后台
											</h4>

											<div class="space-6"></div>

											<form id="login" th:action="@{/login}" method="post">
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" id="username"  name="username"  class="form-control" placeholder="用户名" />
															<i class="icon-user"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" id="password"  name="password"  class="form-control" placeholder="密码" />
															<i class="icon-lock"></i>
														</span>
													</label>

													<div class="space"></div>

													<div class="clearfix">
														<label class="inline">
															<input type="checkbox" id="rememberMe" class="ace" />
															<span class="lbl">记住我</span>
														</label>
														<button type="button" onclick="login()" class="width-35 pull-right btn btn-sm btn-primary">
															<i class="icon-key"></i>
															 登陆
														</button>
													</div>

													<div class="space-4" >
													</div>
												</fieldset>
											</form>

										</div><!-- /widget-main -->
										<div class="toolbar clearfix ">
											<h4 class="header bolder text-center" >
											  系统联系方式	QQ:271102596
											</h4>
										</div>
									</div><!-- /widget-body -->
								</div><!-- /login-box -->
							</div><!-- /position-relative -->
						</div>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div>
		</div><!-- /.main-container -->
		<input type="hidden" id="error" th:value="${error}"/>
		<!-- basic scripts -->
		<script type="text/javascript" th:src="@{/js/ace/jquery-1.10.2.min.js}"></script>
		<script type="text/javascript" th:src="@{/js/ace/bootstrap.min.js}"></script>
		<script type="text/javascript" th:src="@{/js/common.js}"></script>
		<script type="text/javascript" th:src="@{/js/check.js}"></script>
		<script type="text/javascript" th:src="@{/js/jquery.cookie.js}"></script>
		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!--[if lt IE 9]>
		<script  type="text/javascript"  th:src="@{/js/ace/html5shiv.js}"></script>
		<script  type="text/javascript"  th:src="@{/js/ace/respond.min.js}"></script>
		<![endif]-->

		<script th:inline="javascript">
			$(function () {
				validateExplore();
				$("#username").focus();
				init();
				$("#username").change(function (){
					check.checkEmpty("username");
				});
				$("#password").change(function (){
					check.checkEmpty("password");
				});
				showError();
			});
			function init(){
				if ($.cookie("rememberMe") == "true") {
					$("#rememberMe").prop("checked", true);
					$("#username").val($.cookie("username"));
					$("#password").val($.cookie("password"));
				}
			}

			function showError(){
				var error = $("#error").val();
				if(error){
					common.modalGlobalMessage(error,"错误",null);
				}
			}

			function saveCookie(){
				if($("#rememberMe").prop('checked')){
					$.cookie("rememberMe", "true", { expires: 7 });
				}else{
					$.cookie("rememberMe", "false", { expires: -1 });
					$.cookie("username", '', { expires: -1 });
					$.cookie("password", '', { expires: -1 });
				}
			}

			function validateExplore(){
				if(common.notAllowExplore()){
					common.modalGlobalMessage('当前浏览器无法使用系统，请使用Firefox Chrome IE9以上的浏览器！<a href="http://www.firefox.com.cn/download/" target="_blank">下载火狐浏览器</a>',"浏览器版本太低","");
					return false;
				}
				return true;
			}

			function login(){
				if(!validateExplore()){
					return false;
				}
				// var loginUrl = /*[[@{/login}]]*/;
				/*<![CDATA[*/
					if(check.checkEmpty("username") & check.checkEmpty("password")){
						saveCookie();
						$("#login").submit();
					}
				/*]]>*/
			}
		</script>
</body>
</html>
